package top.leix.springdemo.compnent;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Component;
import top.leix.springdemo.NowSemester;
import top.leix.springdemo.mapper.TermsMapper;
import top.leix.springdemo.pojo.Terms;
@Component  
public class StartupRunner {
    @Resource
    TermsMapper termsMapper;

    /**
     * 项目启动附带的任务，获取当前学期
     */
    @PostConstruct  
    public void runAfterInitialization() {  
        // 这里写你想要在项目启动后执行的代码
        Terms nowTerm = termsMapper.selectOne(new QueryWrapper<Terms>().eq("isNow", true));
        NowSemester.setNowSemester(nowTerm.getSemester());
        System.out.println("NowSemester:");
        System.out.println(NowSemester.getNowSemester());
    }  
}